package com.acmen.demo.executor;

import com.acmen.easyapi.model.CustomizePage;
import com.acmen.easyapi.model.Response;
import com.acmen.demo.dto.query.UserListQry;
import com.acmen.demo.dto.query.UserPageQry;
import com.acmen.demo.dto.vo.UserVO;
import com.acmen.demo.repository.UserRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 用户 业务层处理
 *
 * @author acmen
 */
@Service
public class UserQueryExe {
    private static final Logger log = LoggerFactory.getLogger(UserQueryExe.class);
    @Resource
    private UserRepository userRepository;



    /**
     * 分页查询用户信息
     */
    public Response<CustomizePage<UserVO>> selectPage(UserPageQry query) {
        return Response.of(userRepository.selectPage(query));
    }

    public Response<List<UserVO>> selectList(UserListQry query) {
        List<UserVO> users = new ArrayList<UserVO>();
        return Response.of(users);
    }

    public Response<UserVO> selectById(Long id) {
        UserVO user = userRepository.selectById(id);
        return Response.of(user);
    }


    /**
     * 获取当前用户信息
     * @return
     */
    public Response<UserVO> getCurrentUser() {
        Long userId = 2124242L;//获取当前登录的用户
        // 权限集合
        UserVO user = userRepository.selectById(userId);
        return Response.of(user);
    }

}
